package svc

import (
	"github.com/zeromicro/go-zero/core/stores/sqlx"
	"github.com/zeromicro/go-zero/zrpc"
	"microdemo/internal/model/usermodel"
	"microdemo/service/order/internal/config"
	"microdemo/service/user/userclient"
)

type ServiceContext struct {
	Config  config.Config
	UserRpc userclient.User
	// user 表对应 Model
	UserModel usermodel.UserModel
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:  c,
		UserRpc: userclient.NewUser(zrpc.MustNewClient(c.UserRpc)),
		// 注入 UserModel
		UserModel: usermodel.NewUserModel(sqlx.NewMysql(c.Mysql.DataSource)),
	}
}


